package com.maxuxu.scihome.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * @className: SwaggerConfig
 * @author: Maxuxu
 * @date: 2022/6/29 23:08
 * @description:
 */

@Configuration
@EnableSwagger2 // 开启 swagger
public class SwaggerConfig {
    // 自定义配置,修改swagger的默认配置
    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo()); // 需要在下面创建apiInfo方法
    }
    /**
     * 创建api基本信息（这些信息会在文档中展现）
     * 访问地址：http://localhost:8080/swagger-ui.html
     */
    private ApiInfo apiInfo(){
        Contact contact = new Contact("maxuxu", "http://ma.tamad.cf", "1608881588@qq.con");
        return new ApiInfo(
                "这是创建的第一个swagger",
                "swagger api",
                "v1.0",
                "http://localhost:8080",
                contact,
                "Apache 2.0",
                "http://localhost:8080/",
                new ArrayList());
    }
}